Skip to content

feat(v2): expose extract grounding as a top-level keyword - #168

Merged
tian-lan-landing merged 2 commits into
mainfrom
feat/v2-extract-grounding
Sep 17, 2026
Merged

tian-lan-landing merged 2 commits into
mainfrom
feat/v2-extract-grounding

Conversation

@tian-lan-landing

@tian-lan-landing tian-lan-landing commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Wires options.grounding as a top-level grounding= keyword on client.v2.extract and client.v2.extract_jobs.create, mirroring strict. Requested by the API owners for both SDKs — ade-typescript#129 is the identical change with identical semantics.

grounding=False skips the grounding stage: every extraction_metadata leaf comes back with ranges: None and the request finishes faster. Preview; staging has it ahead of production.

Notes:

  • Both shorthands fold into the same nested options object, so _build_extract_body collects them and attaches it once — assigning body["options"] per shorthand (what the code did while strict was alone) would drop whichever landed first.
  • bool(), not truthiness: grounding=False is the only value the flag is ever passed for.
  • Omitted or None leaves the key out, so the server default applies (strict false, grounding true); options is omitted entirely when neither is given.
  • The live contract test asserts the returned ranges are all null rather than a 2xx — a shorthand that never reached the wire is not an error staging reports, it just grounds anyway.
  • CONTRIBUTING.md (the cross-SDK alias registry) and the spec-sync prompt both updated: three aliases now, not two.

Verified against staging: grounding=False → ranges: null, grounding=True → real ranges.

`options.grounding` skips the grounding stage, so every `extraction_metadata`
leaf comes back with `ranges: null` and the request finishes faster. It is
nested inside `options`, which extract does not surface, so it needed a
hand-written top-level shorthand next to `strict` — a cross-SDK decision
CONTRIBUTING.md reserves for a maintainer. The API owners asked for it in both
SDKs, so `ade-typescript` gets the identical keyword with identical semantics.

Both shorthands now fold into the SAME `options` object, so `_build_extract_body`
collects them and attaches it once; assigning `body["options"]` per shorthand
(what the code did while `strict` was alone) would drop whichever landed first.
`bool()` rather than truthiness, since `grounding=False` is the only value the
flag is ever passed for. Omitted or `None` leaves the key out and the server
default applies.

The live check asserts the returned `ranges` are all null rather than a 2xx: a
shorthand that never reached the wire is not an error staging reports — it
grounds anyway and comes back with real ranges.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 17, 2026 02:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The live contract test filters out leaves missing ranges, so it does not verify the stated every-leaf contract.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Exposes grounding= across all V2 extract entry points, folding it with strict into the nested API options.

Changes:

  • Adds synchronous and asynchronous grounding support.
  • Adds request-body and live contract coverage.
  • Updates public documentation and cross-SDK alias guidance.
File summaries
File Description
src/landingai_ade/resources/v2/extract.py Builds and sends the grounding option.
src/landingai_ade/resources/v2/v2.py Exposes the top-level keyword.
tests/api_resources/v2/test_extract.py Tests synchronous and job requests.
tests/api_resources/v2/test_async_smoke.py Tests asynchronous entry points.
tests/contract/test_v2_smoke.py Adds live grounding verification.
README.md Documents user-facing behavior.
api.md Updates API signatures and semantics.
docs/v2-testing.md Documents implementation and testing details.
CONTRIBUTING.md Records cross-SDK alias rules.
.github/workflows/spec-sync.yml Updates spec-sync alias guidance.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/contract/test_v2_smoke.py Outdated
…he ones that do

Copilot review: filtering the live check to leaves that HAVE `ranges` let a leaf
that dropped the key pass as if it had been checked. The schema is flat, so every
top-level entry is a leaf and the documented contract is that all of them carry
`ranges: null` with grounding off — assert the key's presence separately from its
value.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 17, 2026 07:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation consistently handles omission and explicit false values across every sync and async extraction path with comprehensive coverage.

Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@tian-lan-landing
tian-lan-landing merged commit ac4dbbf into main Sep 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants